I'm using javascripts fetch() method to check if a file on the server exists, if not i want to fallback to fetching another default file. In this article I allready learned that JS does not throw an error if the request results in an 404 Error, but sets response.ok to false.
So my code looks like this now:
let resp;
resp = await fetch("url1"); //check for custom file at url1
if (!resp.ok) { resp = await fetch("url2"); } //if not found use default file at url2
It work's as expected, but: if the first request returns a 404-Status Code the console allways shows an error for the 404 Response. I dont want to see the Error in the console because it looks like an application error, but just means that the default file was loaded... Any Ideas how to fix this? I'm using Chrome and it looks like this: